package o;

import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat.d;
import com.huawei.hwid.core.constants.HwAccountConstants;
import java.util.List;
import o.bob.e;

public class bpi {
    private static final bpi ˋ = new bpi();
    private static final String ॱ = bpi.class.getName();
    private final bkr ˊ = new bkr();
    private final Context ˏ = ContentManager.getInstant().getContext();

    @NonNull
    public static bpi ˎ() {
        return ˋ;
    }

    private bpi() {
    }

    private synchronized d ˏ(int i) {
        d dVar;
        dVar = (d) this.ˊ.ˋ((long) i);
        if (dVar == null) {
            bol ˋ = bor.ˎ().ˋ(i);
            if (ˋ == null) {
                boc.ˎ.ˊ("NotifiBarManager", "Not found the session, sessionId: " + i);
                dVar = null;
            } else {
                String ˋ2 = ˋ.ˋ();
                List ॱˎ = ˋ.ॱˎ();
                boolean z = !ˋ.ॱᐝ().isEmpty();
                dVar = new d(this.ˏ).ˏ(false).ˊ(true).ॱ(true).ˏ(-1).ˊ(bob.d.ˋ).ˎ(null).ˏ(null);
                String ˎ = bla.ˎ(this.ˏ, ˋ2);
                String ˎ2 = ˎ(ˋ2, ॱˎ, z);
                dVar.ˏ(this.ˏ.getResources().getString(e.ˋ, new Object[]{ˎ, ˎ2}));
                dVar.ˊ(100, 0, false);
                PendingIntent ˋ3 = ˋ(ˋ);
                if (ˋ3 != null) {
                    dVar.ˎ(ˋ3);
                }
                this.ˊ.ॱ((long) i, dVar);
            }
        }
        return dVar;
    }

    private synchronized void ॱ(int i) {
        if (((d) this.ˊ.ˋ((long) i)) != null) {
            this.ˊ.ˏ((long) i);
        }
    }

    public void ˊ(int i) {
        ˊ(i, 0);
    }

    public void ˊ(int i, int i2) {
        d ˏ = ˏ(i);
        if (ˏ != null) {
            ˏ.ˊ(100, Math.min(i2, 100), false);
            cei.ॱ(this.ˏ, ॱ, bol.ˏ(i), ˏ);
        }
    }

    public void ˎ(int i) {
        ॱ(i);
        cei.ˋ(this.ˏ, ॱ, bol.ˏ(i));
    }

    @NonNull
    private String ˎ(@NonNull String str, @NonNull List<Integer> list, boolean z) {
        StringBuilder stringBuilder = new StringBuilder();
        if (!list.isEmpty()) {
            stringBuilder.append(bla.ˎ(this.ˏ, str, ((Integer) list.get(0)).intValue()));
            for (int i = 1; i < list.size(); i++) {
                stringBuilder.append(", ");
                stringBuilder.append(bla.ˎ(this.ˏ, str, ((Integer) list.get(i)).intValue()));
            }
            if (z) {
                stringBuilder.append(", ");
            }
        }
        if (z) {
            stringBuilder.append(this.ˏ.getResources().getString(e.ॱ));
        }
        return stringBuilder.toString();
    }

    @Nullable
    private PendingIntent ˋ(@NonNull bol o_bol) {
        int ॱ = o_bol.ॱ();
        Intent ˋ = bof.ˊ().ˋ();
        if (ˋ == null) {
            boc.ˎ.ˊ("NotifiBarManager", "'ApiFactory.getDependApi().getPendingIntent()' return null.");
            return null;
        }
        ˋ.putExtra("int.sessionId", o_bol.ˏ());
        return PendingIntent.getActivity(this.ˏ, ॱ, ˋ, HwAccountConstants.FLAG_TRANS_NAVIGATION_BAR);
    }
}
